#include <iostream>
#include <iomanip>
using namespace std;

#include "ClassTimeConst.h"

Time::Time(int hour, int minute, int second) 
{
	setTime(hour, minute, second);
}
Time::~Time()
{
	cout << "ObjectID= " << hour << endl;
}
Time *Time::setTime(int hour, int minute, int second)
{
	setHour(hour);
	setMinute(minute);
	setSecond(second);
	return this;
}
Time &Time::setHour(int h)
{
	hour = (h>=0 && h<24) ? h : 0; 
	return *this;
}
Time &Time::setMinute(int m)
{
	minute = (m>=0 && m<=59) ? m : 0;
	return *this;
}
Time &Time::setSecond(int s)
{
	second = (s > 0 && s <= 59) ? s : 0;
	return *this;
}
int Time::getHour() const
{
	return hour;
}
int Time::getMinute() const
{
	return minute;
}
int Time::getSecond() const
{
	return second;
}
Time &Time::printTimeUniversal() const
{
	cout << setfill('0') << setw(2) << hour << ":"
			<< setw(2) << minute << ":"
			<< setw(2) << second << endl; 
	//return *this;
}
void Time::printTimeStandard()
{
	cout << setfill('0') << setw(2) << ((hour==0 || hour == 12) ? 12 : hour%12)  << ":"
			<< setw(2) << minute << ":"
			<< setw(2) << second << (hour<12 ? "AM" : "PM") << endl;
}

